import Vue from 'vue'
import Vuex from 'vuex'
import { getDmyList } from '../libs/utile.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
	  headerTitile: '当天信息',
	  placeholder: '格式：20210104(2021年01月04日)',
	  maxleng: 8,
	  daydetail: '5555',
	  dmyList:[
		  {
			iconDay: getDmyList('day'),
			icontext: '当天',
			path: '/Day'
		  },
		  {
			iconDay: getDmyList('mouth'),
			icontext: '当月',
			path: '/Mouth'
		  },
		  {
			iconDay: getDmyList('year'),
			icontext: '当年',
			path: '/Year'
		  },
	]
  },
  mutations: {
	  setHearTitile(state,routerName){
		switch(routerName){
			case 'day':
				state.headerTitile = '当天信息'
				break
			case 'mouth':
				state.headerTitile = '近期假期'
				break
			case 'year':
				state.headerTitile = '当年假期'
				break
			default:
				state.headerTitile = '当天信息'
		}
	  },
	  setPlaceholder(state,routerName){
		const date = new Date();
		const year = date.getFullYear();
		const mouth = (date.getMonth() + 1).toString().padStart(2,'0');
		const day = date.getDate().toString().padStart(2,'0')
		switch(routerName){
			case 'day':
				state.placeholder = `格式：${year}${mouth}${day}(${year}年${mouth}月${day}日)`
				state.maxleng = 8
				break
			case 'mouth':
				state.placeholder = `格式：${year}${mouth}(${year}年${mouth}月)`
				state.maxleng = 6
				break
			case 'year':
				state.placeholder = `格式：${year}(${year}年)`
				state.maxleng = 4
				break
		}
	  }
  },
  actions: {
  },
  modules: {
  }
})
